

const fs = require("fs")

// 读取文件
exports.readHtmlFiles = function(path,req,res){
    fs.readFile(path,"utf8",(err,data)=>{
       if(err) throw err;
       res.writeHead(200,{'content-Type':'text/html;charset=utf8'});
       res.write(data)
       res.end()
    })
}


exports.readJsonFiles = function(path,req,res){
  fs.readFile(path,"utf8",(err,data)=>{
     if(err) throw err;
     res.writeHead(200,{'content-Type':'application/json'});
     res.write(data)
     res.end()
  })
}

exports.readImgFiles = function(path,req,res){
  fs.readFile(path,"binary",(err,data)=>{
     if(err) throw err;
     res.writeHead(200,{'content-Type':'image/jpeg'});
     res.write(data,'binary')
     res.end()
  })
}